﻿using B.S.BasicData.Domain;
using B.S.BasicData.EroorCode;
using MediatR;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("api/[controller]")]
public class BreedingInfoController : ControllerBase
{
    private readonly IMediator _mediator;
    public BreedingInfoController(IMediator mediator)
    {
        _mediator = mediator;
    }

    [HttpPost("update")]
    public async Task<ActionResult<ApiResult<BreedingInfo>>> Update([FromBody] BreedingInfoUpdateRequest request)
    {
        var result = await _mediator.Send(request);
        return Ok(result);
    }

    /// <summary>
    /// 修改
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpPost("get-by-id")]
    public async Task<ActionResult<ApiResult<B.S.BasicData.Domain.BreedingInfo>>> GetById([FromQuery] int id)
    {
        var result = await _mediator.Send(new BreedingInfoGetByIdRequest { Id = id });
        return Ok(result);
    }

    [HttpGet("batch-query")]
    public async Task<ActionResult<ApiResult<System.Collections.Generic.List<B.S.BasicData.ApiRead.BreedingInfoBatchDto>>>> BatchQuery([FromQuery] string batchNo)
    {
        var result = await _mediator.Send(new BreedingInfoBatchQuery { BatchNo = batchNo });
        return Ok(result);
    }

    [HttpGet("get-dto-by-id")]
    public async Task<ActionResult<ApiResult<B.S.BasicData.ApiRead.BreedingInfoDto>>> GetDtoById([FromQuery] int id)
    {
        var result = await _mediator.Send(new BreedingInfoDtoGetByIdRequest { Id = id });
        return Ok(result);
    }
}